package nio.example.study.client.codec.dispatcher;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import nio.example.study.common.ResponseMessage;

public class ResponseDispatcherHandler extends SimpleChannelInboundHandler<ResponseMessage> {

	private RequestPendingCenter requestPendingCenter;

	public ResponseDispatcherHandler(RequestPendingCenter requestPendingCenter) {
		this.requestPendingCenter = requestPendingCenter;
	}


	@Override
	protected void channelRead0(ChannelHandlerContext ctx, ResponseMessage msg) throws Exception {
		requestPendingCenter.set(msg.getMessageHeader().getStreamId(), msg.getMessageBody());
	}
}
